import { get, post, put, del } from '@/utils/request'

// 获取日记列表
export const getDiariesAPI = (params) => {
  return get('/api/diaries', {
    page: params.page || 1,
    limit: params.limit || 10,
    categoryId: params.categoryId,
    tagIds: params.tagIds,
    startDate: params.startDate,
    endDate: params.endDate,
    keyword: params.keyword,
    sortBy: params.sortBy || 'created_at',
    sortOrder: params.sortOrder || 'desc'
  })
}

// 获取日记详情
export const getDiaryDetailAPI = (id) => {
  return get(`/api/diaries/${id}`)
}

// 创建日记
export const createDiaryAPI = (data) => {
  return post('/api/diaries', {
    title: data.title,
    content: data.content,
    diaryDate: data.diaryDate,
    categoryId: data.categoryId,
    tagIds: data.tagIds,
    weather: data.weather,
    mood: data.mood,
    images: data.images
  })
}

// 更新日记
export const updateDiaryAPI = (id, data) => {
  return put(`/api/diaries/${id}`, data)
}

// 删除日记
export const deleteDiaryAPI = (id) => {
  return del(`/api/diaries/${id}`)
}

// 搜索日记
export const searchDiariesAPI = (params) => {
  return get('/api/diaries/search', {
    keyword: params.keyword,
    page: params.page || 1,
    limit: params.limit || 20,
    categoryId: params.categoryId,
    tagIds: params.tagIds,
    startDate: params.startDate,
    endDate: params.endDate
  })
} 